import gameConfig from "../../engines/configs/gameConfig";
import O1HD from "../../engines/gameEngine";
import mainRoot from "../../Game/MainRoot";

const {ccclass, property} = cc._decorator;

@ccclass
export default class attention extends cc.Component {


    // LIFE-CYCLE CALLBACKS:

    // onLoad () {}

    onEnable()
    {
        if(window['tt']&&gameConfig.DOUYIN_YUMAI==1&&mainRoot.platName != "novelapp")
        {
            let Platname:string=null
            let self=this;
            window['tt'].getSystemInfo({
                success:(res)=>{
                    Platname = res.appName;
                    if(Platname!="Douyin")
                    {
                        self.node.active=false
                    }
                    window['tt'].checkFollowAwemeState({
                      success(res) {
                        console.log("调用成功", res);
                        if(res.hasFollowed)
                        {
                            self.node.active=false
                        }
                      },
                      fail(res) {
                        console.log("调用失败", res);
                      },
                    });
                },
                fail:(res)=>{
                    console.log(`getSystemInfo 调用失败`);
                    self.node.active=false
                },
            });
        }else
        {
            this.node.active=false
        }
    }

    
    
    OnClickAttention()
    {
        O1HD.getManagers().soundMgr.playSound('mainSound/anNiu').then();
        if(window['tt'])
        {
            let self=this;
            window['tt'].openAwemeUserProfile({
                success: (res) => {
                  console.log(res);
                  if(res.hasFollowed)
                  {
                      self.node.active=false
                  }
                },
                fail:(err)=>{
                    console.warn("失败---",err)
                }
            });
        }
    }

    // update (dt) {}
}
